import * as THREE from 'three';
import { config } from './config.js';
var iconGroup = new THREE.Group();

var textureLoader = new THREE.TextureLoader();




config.posIcons.forEach(element => {
    var type = element.type;
    var map = textureLoader.load( element.mapUrl );
    var color = element.color
    var SpriteMaterial = new THREE.SpriteMaterial( { map: map ,transparent: true,color:color,depthTest:false} ); 
    // console.log(SpriteMaterial);
    element.devices.forEach(device => {
        if(device.color)
        {
            SpriteMaterial.color.set(new THREE.Color(device.color));
        }
        var Sprite = new THREE.Sprite( SpriteMaterial );
        var pos = device.pos;
        Sprite.position.set(-pos.x + config.building.sX / 2,pos.y,-pos.z +  config.building.sY / 2);
        Sprite.scale.set(element.scale.x,element.scale.y,1);
        Sprite.name = "posIcon_"+device.name;
        Sprite.videoUrl = device.videoUrl;
        Sprite.uType = type;
        iconGroup.add(Sprite);
    })
});


export { iconGroup };



